{extend name='table'}

{block name="button"}
    <button class="layui-btn layui-btn-sm" data-modal='{:url("add")}'>
        <i class="layui-icon layui-icon-add-1"></i> 新增兑换
    </button>
    <button class="layui-btn layui-btn-sm layui-btn-danger" data-table-id="ExchangeTable" data-action='{:url("remove")} ' data-rule="id#{id}">
        <i class="layui-icon layui-icon-delete"></i> 删除
    </button>
{/block}

{block name="search"}
    <form class="layui-form layui-form-pane form-search" id="ExchangeSearchForm" data-table-id="ExchangeTable" onsubmit="return false">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">礼品名</label>
            <div class="layui-input-inline">
                <input name="gift_name" value="{$get.gift_name|default=''}" placeholder="请输入礼品名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">会员姓名</label>
            <div class="layui-input-inline">
                <input name="member_name" value="{$get.member_name|default=''}" placeholder="请输入会员姓名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input name="member_phone" value="{$get.member_phone|default=''}" placeholder="请输入手机号" class="layui-input">
            </div>
        </div>
        {if $isMaster}
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">门店</label>
            <div class="layui-input-inline">
                <select name="store_id">
                    <option value="">- 全部 -</option>
                    {foreach $stores as $s}
                    <option value="{$s.id}" {if input('get.store_id') == $s.id}selected{/if}>{$s.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">操作员ID</label>
            <div class="layui-input-inline">
                <input name="operator_id" value="{$get.operator_id|default=''}" placeholder="可选" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-inline">
                <input data-date-range name="create_time" value="{$get.create_time|default=''}" placeholder="- 选择时间范围 -" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <button class="layui-btn" type="submit"><i class="layui-icon layui-icon-search"></i> 搜 索</button>
            <button class="layui-btn layui-btn-primary" type="reset"><i class="layui-icon layui-icon-refresh-1"></i> 重 置</button>
        </div>
    </form>
{/block}

{block name="content"}
    <table id="ExchangeTable" data-url="{:sysuri('index')}" data-target-search="form.form-search"></table>
{/block}

{block name="script"}
<script>
layui.use(['jquery'], function () {
  var $ = layui.$;
  let cols = [
    {type:'checkbox'}, {field:'id', title:'ID', width:70, sort:true},
    {field:'member_name', title:'会员姓名', width:120},
    {field:'member_phone', title:'手机号', width:120},
    {field:'gift_name', title:'礼品', minWidth:150},
    {field:'points', title:'积分', width:90, sort:true},
    {field:'store_name', title:'门店', width:140},
    {field:'operator_name', title:'操作员', width:120},
    {field:'create_time', title:'时间', width:170, sort:true},
    {field:'remark', title:'备注', minWidth:160},
    {toolbar:'#ToolbarTpl', title:'操作', minWidth:120, fixed:'right'}
  ];
  $('#ExchangeTable').layTable({ even:true, height:'full-200', cols: [cols] });
});
</script>

<script type="text/html" id="ToolbarTpl">
    <a class="layui-btn layui-btn-danger layui-btn-xs" data-confirm="确定要删除该记录吗？" data-action='{:url("remove")}' data-value="id={{d.id}}">删 除</a>
</script>
{/block}
